class User {
  final String id; // 将 id 的类型从 int 改为 String
  final String login;
  final String name; // 添加 name 字段
  final String avatarUrl;
  final String? bio; // 可选的 bio
  final String? blog; // 可选的 blog
  final String? company; // 可选的 company
  final String email;
  final int followers;
  final int following;
  final String htmlUrl;
  final String type;
  final String url;

  User({
    required this.id,
    required this.login,
    required this.name, // name 字段也需要
    required this.avatarUrl,
    this.bio,
    this.blog,
    this.company,
    required this.email,
    required this.followers,
    required this.following,
    required this.htmlUrl,
    required this.type,
    required this.url,
  });

  factory User.fromJson(Map<String, dynamic> json) {
    return User(
      id: json['id'] as String, // 确保这里转换为 String
      login: json['login'] as String,
      name: json['name'] as String, // 解析 name 字段
      avatarUrl: json['avatar_url'] as String,
      bio: json['bio'] as String?, // 使用 as String? 来处理可能为 null 的情况
      blog: json['blog'] as String?,
      company: json['company'] as String?,
      email: json['email'] as String,
      followers: json['followers'] as int,
      following: json['following'] as int,
      htmlUrl: json['html_url'] as String,
      type: json['type'] as String,
      url: json['url'] as String,
    );
  }
}
